﻿//表单值转换JSON
function Form2Json(Form) {
    var serializeObj = {};
    $($(Form).serializeArray()).each(function () {
        if (serializeObj.hasOwnProperty(this.name)) {//多选按钮 或者需要多项答案
            serializeObj[this.name] += "," + this.value;
        } else {
            serializeObj[this.name] = this.value;
        }
    });
    return serializeObj;
}

//获取URL后参数  通过参数名称
function getUrlparame(parame) {
    var reg = new RegExp("(^|&)" + parame + "=([^&]*)(&|$)", "i");
    var search = decodeURI(window.location.search)
    var r = search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

//时间戳转时间
function TimeStampToDate(ts) {
    ts = /\d+/.exec(ts);
    return (new Date(parseInt(ts))).toLocaleDateString();
}

//格式化时间 转换成  yyyy-MM-dd
function FormaDate(d) {
    var date = new Date(d);
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    return year + "-" + (month > 9 ? month : "0" + month) + "-"+(day > 9 ? day : "0" + day);
}